package com.liull.netty.protobuf;

import java.net.InetSocketAddress;
import java.net.SocketAddress;

import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;

/**
 * @Author: liull
 * @Description:
 * @Date: Created in 21:02 2020/9/27
 * @Modified By:
 */
public class ProtoClient {
    public static void main(String[] args) throws InterruptedException {
        // 客户端只需要一个线程组 用来发送消息
        EventLoopGroup eventLoopGroup = new NioEventLoopGroup();
        try {
            Bootstrap bootstrap = new Bootstrap();
            SocketAddress address = new InetSocketAddress("127.0.0.1", 8888);
            bootstrap.group(eventLoopGroup)
                    .channel(NioSocketChannel.class)
                    .handler(new ProtoClientInitializer());
            ChannelFuture channelFuture = bootstrap.connect(address).sync();
            channelFuture.channel().closeFuture().sync();
        } finally {
            eventLoopGroup.shutdownGracefully().sync();
        }

    }
}
